# -*- coding: utf-8 -*-
from multiprocessing import Process
from py_process.py_managers.py_client import ClientManager
import sys
import time
import logging

logger = logging.getLogger(__name__)


def logger_config():
    logger_format = '%(asctime)s.%(msecs)03d %(processName)24s %(funcName)16s %(lineno)3d  %(message)s'
    logging.basicConfig(format=logger_format, datefmt='%H:%M:%S', level=logging.INFO, stream=sys.stdout)
    pass


def worker_client(flag):
    client_manager = ClientManager(
        address=('127.0.0.1', 5000), authkey=b'chench')
    client_manager.connect()

    master_queue = client_manager.get_master_queue()
    worker_queue = client_manager.get_worker_queue()
    for i in range(10):
        if flag == 0:
            logger.info('master_queue=%s:%s', i, master_queue.get())
        elif flag == 1:
            logger.info('worker_queue=%s:%s', i, worker_queue.get())
        pass

    pass


if __name__ == '__main__':

    for i in range(1):
        worker = Process(target=worker_client, args=(i,))
        worker.start()
        pass
    # time.sleep(60 * 3)
    pass
